{include file='common/element-header'}


<div id="app">

    <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="活动名称">
            <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="活动区域">
            <el-select v-model="region_seleted" placeholder="请选择活动区域">
                <el-option v-for='(item,index) in region_list' :label="item.title" :value="item.id"></el-option>
            </el-select>
        </el-form-item>

        <el-form-item label="缴费方式">
            <el-switch
                    v-model="form.type"
                    active-text="按年缴费"
                    inactive-text="按月缴费"
                    active-value:1
                    inactive-value:2>


            </el-switch>
        </el-form-item>

        <el-form-item label="活动形式">
            <el-input type="textarea" v-model="form.desc"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">提交</el-button>
            <el-button>取消</el-button>
        </el-form-item>
    </el-form>

</div>


<script>

    new Vue({
        el:      '#app',
        data () {
            return {
                member:         'zhangsan',
                form:           {
                    name:   '',
                    region: '',
                    desc:   '',
                    type:   '2'
                },
                region_list:    '',
                region_seleted: ''
            }
        },
        mounted () {
            this.getDefault();
            this.getRegion();
        },
        methods: {
            //获取区域
            getRegion () {
                this.$request.get({
                    url: 'index/demo/getRegion'
                }).then((res) => {
                    if (res.code == 1) {
                        this.region_list = res.data;
                        this.region_seleted = res.data[0].id
                    } else {
                        this.$message(res.msg);
                        return
                    }
                })
            },

            getDefault () {
                this.$request.get({
                    url: 'index/demo/getDefault'
                }).then((res) => {
                    if (res.code == 1) {
                        this.form = res.data;
                        this.region_seleted = res.data.region;
                    } else {
                        this.$message(res.msg);
                        return
                    }
                    console.log('this.form:', this.form);
                })
            },

            //表单提交
            onSubmit () {

                console.log('onSubmit form:', this.form);
                return
                this.$request.post({
                    url:  'index/demo/index',
                    data: this.form,
                }).then((res) => {
                    console.log("onSubmit res:", res)
                })


            }


        }
    })

</script>


{include file='common/element-footer'}

